package leetcode.code0669;

import leetcode.IDebug;
import leetcode.helper.tree.TreeNode;

public class Solution implements IDebug {

	public TreeNode trimBST(TreeNode root, int low, int high) {
		if (root == null) {
			return null;
		}
		int val = root.val;
		if (val < low) {
			return this.trimBST(root.right, low, high);
		} else if (val > high) {
			return this.trimBST(root.left, low, high);
		} else {
			root.left = this.trimBST(root.left, low, high);
			root.right = this.trimBST(root.right, low, high);
			return root;
		}
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
